home *** CD-ROM | disk | FTP | other *** search
/ Magnum One / Magnum One (Mid-American Digital) (Disc Manufacturing).iso / d12 / cbibcode.arc / STRSTR.C < prev    next >
Encoding:
C/C++ Source or Header  |  1991-08-05  |  498 b   |  22 lines

  1. /* strstr.c  From TC Bible page 300  Use strstr to locate the first occurrence
  2. of one string in another. */
  3.  
  4. #include <stdio.h>
  5. #include <string.h>
  6. main()
  7. {
  8.     char str1[80], str2[80], *result;
  9.     printf("Enter a string: ");
  10.     gets(str1);
  11.     printf("Enter a string to locaate in the first: ");
  12.     gets(str2);
  13.     if((result = strstr(str1, str2)) == NULL)
  14.     {
  15.         printf("\"%s\" NOT IN \"%s\"\n", str2, str1);
  16.     }
  17.     else
  18.     {
  19.         printf("\"%s\" FOUND.\n\Rest of string: %s\n",
  20.         str2, result);
  21.     }
  22. }